/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgUtil.pkgFrameworkXML.pkgEntity;

import java.io.File;
import org.jdom2.Element;
import org.jdom2.Namespace;

/**
 *
 * @author Administrador
 */
public class WXmlObject extends XmlObject {

    private Element root;

    public WXmlObject(String fileXml, String fileXsd, String nameRoot) {
        super(fileXml, fileXsd);
        root = new Element(nameRoot);
        setXsd();
    }

    /**
     * @return the root
     */
    public Element getRoot() {
        return root;
    }

    private void setXsd() {
        if (getFileXsd() != null) {
            File fXsd = new File(getFileXsd());
            if (!fXsd.exists()) {
                return;
            }

            Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            root.addNamespaceDeclaration(ns);
            root.setAttribute("noNamespaceSchemaLocation", getFileXsd(), ns);
        }
    }
}
